import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86138
 * Date: 2024-10-18
 * Time: 20:30
 */
//定义一个类实现电话卡的概念，包括的变量有"卡号"、"余额"、"密码"，
        //包括的方法有"拨号"、"扣款"、"查询余额"。定义主类，创建卡号类的对象，并完成相应操作。
public class Telephone {
    String num;
    double balance;
    String password;

    //构造方法
    public Telephone(String num,double balance,String password){
        this.num = num;
        this.balance = balance;
        this.password = password;
    }

    //拨号
    public void ring(){
        Scanner sc = new Scanner(System.in);
        System.out.print("请输入要拨打的电话->");
        String ret = sc.nextLine();
        System.out.println("····正在拨号"+ret+"····");
        try {
            Thread.sleep(3000); // 暂停 3 秒钟
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("已接通");
    }

    //扣款
    public void reduce(double money){
        if (balance >= money) {
            balance -= money;
            System.out.println("成功扣款 " + money + " 元，余额为 " + balance + " 元。");
        } else {
            System.out.println("余额不足，无法扣款。");
        }
    }

    //查询余额
    public void balance(double balance){
        System.out.println("余额剩余->"+balance+"元");
    }
}
